<?php
    /******************************************************************************
     *    Copyright ZhangYue
     * Author:                Quinn Xu
     * Description:           各类接口
     * Want argument:         
     * Output:                
     * Create Date:           2012-12-18
     *****************************************************************************/
    include_once 'config.inc.php';
    $action = $_GET['action'];
    switch($action)
    {
        case 'peizhi':
            peizhi();
            break;
		case 'jiaoshi':
			jiaoshi();
			break;
		case 'tianjia_jiaoshi':
			tianjia_jiaoshi();
			break;
		case 'shanchu_jiaoshi':
			shanchu_jiaoshi();
			break;
    }
    
    //配置属性值
    function peizhi()
    {
        $id = $_GET['id'];
        $shuxingzhi = $_GET['shuxingzhi'];
        include_once DATACLASS . 'peizhi.class.php';
        include_once DATACLASS . 'peizhiguanli.class.php';
        $peizhi = new peizhi();
        $peizhiguanli = new peizhiguanli();
        $peizhi->setId($id);
        $peizhi->setShuxingzhi($shuxingzhi);
        $peizhiguanli->peizhishuxingzhi($peizhi);
    }

	//配置教师数据表信息
	function jiaoshi()
	{
		$id = $_GET['id'];
		$banji = $_GET['banji'];
		$kemu = $_GET['kemu'];
		$xingming = $_GET['xingming'];
		$miaoshu = $_GET['miaoshu'];
		include_once DATACLASS . 'jiaoshi.class.php';
		include_once DATACLASS . 'jiaoshiguanli.class.php';
		$jiaoshi = new jiaoshi();
		$jiaoshiguanli = new jiaoshiguanli();
		$jiaoshi->setId($id);
		$jiaoshi->setBanji($banji);
		$jiaoshi->setKemu($kemu);
		$jiaoshi->setXingming($xingming);
		$jiaoshi->setMiaoshu($miaoshu);
		$result = $jiaoshiguanli->genggaijiaoshixinxi($jiaoshi);
		genggaijieguo($result);
	}

	//添加新的教师信息
	function tianjia_jiaoshi()
	{
		$banji = $_GET['banji'];
		$kemu = $_GET['kemu'];
		$xingming = $_GET['xingming'];
		$miaoshu = $_GET['miaoshu'];
		include_once DATACLASS . 'jiaoshi.class.php';
		include_once DATACLASS . 'jiaoshiguanli.class.php';
		$jiaoshi = new jiaoshi();
		$jiaoshiguanli = new jiaoshiguanli();
		$jiaoshi->setBanji($banji);
		$jiaoshi->setKemu($kemu);
		$jiaoshi->setXingming($xingming);
		$jiaoshi->setMiaoshu($miaoshu);
		$jiaoshiguanli->tianjiajiaoshixinxi($jiaoshi);
		genggaijieguo($result);
	}

	//删除教师操作
	function shanchu_jiaoshi()
	{
		$id = $_GET['id'];
		include_once DATACLASS . 'jiaoshi.class.php';
		include_once DATACLASS . 'jiaoshiguanli.class.php';
		$jiaoshi = new jiaoshi();
		$jiaoshiguanli = new jiaoshiguanli();
		$jiaoshi->setId($id);
		$jiaoshiguanli->shanchujilu($jiaoshi);
	}

	//判断是否执行成功,SQL增删改操作
	function genggaijieguo($result)
	{
		if($result)
		{
			$array = array("status"=>"ok","data"=>array("msg"=>"操作成功"));
		}
		else
		{
			$array = array("status"=>"error","data"=>array("msg"=>"操作失败!请检查\n1.添加操作:信息是否填写完整\n2.更新操作:提交的内容是否和原来的一样"));
		}
		echo json_encode($array);
	}
?>